﻿<?php
class User extends AppModel {
	var $name = 'User';
	var $displayField = 'user_name';
	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $validate = array(
		'user_name' => array(
			'rule' => 'notEmpty',
			'message' => 'Nhap user name'
		),
		'matkhau' => array(
			'rule' => 'notEmpty',
			'message' => 'mat khau trong'
		),
	);

	var $hasMany = array(
		'Message' => array(
			'className' => 'Message',
			'foreignKey' => 'user_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Userpost' => array(
			'className' => 'Userpost',
			'foreignKey' => 'user_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Reply' => array(
			'className' => 'Reply',
			'foreignKey' => 'user_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Savedmessage' => array(
			'className' => 'Savedmessage',
			'foreignKey' => 'user_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	); 
    function checkLogin($username,$password){
        $sql="SELECT hoten from users where user_name='$username' and matkhau='$password'";
        $this->query($sql);
        if($this->getNumRows()==0){
            return false;
        }else{
            return true;
        }
    }

}
